package com.lotter.common.enumobject;

import com.lotter.common.util.StringUtil;

//比分
public enum ScoreEnum {

	
	  S_1_0(1, "1:0"),
	  S_2_0(2, "2:0"),
	  S_2_1(3, "2:1"),
	  S_3_0(4, "3:0"),
	  S_3_1(5, "3:1"),
	  S_3_2(6, "3:2"),
	  S_4_0(7, "4:0"),
	  S_4_1(8, "4:1"),
	  S_4_2(9, "4:2"),
	  S_5_0(10, "5:0"),
	  S_5_1(11, "5:1"),
	  S_5_2(12, "5:2"),
	  S_S_Q(13, "胜其他"),
	  S_0_0(14, "0:0"),
	  S_1_1(15, "1:1"),
	  S_2_2(16, "2:2"),
	  S_3_3(17, "3:3"),
	  S_P_Q(18, "平其他"),
	  S_0_1(19, "0:1"),
	  S_0_2(20, "0:2"),
	  S_1_2(21, "1:2"),
	  S_0_3(22, "0:3"),
	  S_1_3(23, "1:3"),
	  S_2_3(24, "2:3"),
	  S_0_4(25, "0:4"),
	  S_1_4(26, "1:4"),
	  S_2_4(27, "2:4"),
	  S_0_5(28, "0:5"),
	  S_1_5(29, "1:5"),
	  S_2_5(30, "2:5"),
	  S_F_Q(31, "负其他");


	private int code;
	private String desc;

	private ScoreEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int getCode() {
		return code;
	}

	public String getDesc() {
		return desc;
	}
	
	public static Integer judgeCode(String scope){
		if(StringUtil.isBlank(scope)){
			return null;
		}
		
		scope = scope.trim().replace(" ", "");
		for (ScoreEnum type : values()) {
		  if(scope.equals(type.getDesc())){
			  return type.getCode();
		  }
		}
		String[] arrayScore = scope.split(":");
		int home = Integer.parseInt(arrayScore[0]);
		int away = Integer.parseInt(arrayScore[1]);
		if(home > away){
			return ScoreEnum.S_S_Q.getCode();
		}else if(home == away){
			return ScoreEnum.S_P_Q.getCode();
		}else{
			return ScoreEnum.S_F_Q.getCode();
		}
	}
	
	
	public static String getName(int i){
		for (ScoreEnum type : values()) {
			if(type.getCode()==i){
				return type.getDesc();
			}
		}
		return null;
	}

	
}
